import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    port: 3001,
    hmr: true,
    proxy: {
      "/dev-api": {
        target: "http://localhost:8080",  // 假设网关运行在8080端口，请根据实际情况调整
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev-api/, ''),
      },
      "/api": {
        target: "http://localhost:8080",  // 假设网关运行在8080端口，请根据实际情况调整
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      }

    }
  }
})
